package com.tiger.cloud.util;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.TypeHandler;

public class DateTypeHandler implements TypeHandler<Date> {

	@Override
	public void setParameter(PreparedStatement ps, int i, Date parameter, JdbcType jdbcType) throws SQLException {
		ps.setDate(i, new java.sql.Date(parameter.getTime()));
	}

	@Override
	public Date getResult(ResultSet arg0, int columnName) throws SQLException {
		return arg0.getDate(columnName);
	}

	@Override
	public Date getResult(ResultSet arg0, String columnName) throws SQLException {
		return arg0.getDate(columnName);
	}

	@Override
	public Date getResult(CallableStatement arg0, int arg1) throws SQLException {
		return arg0.getDate(arg1);
	}

}